<!DOCTYPE html>
<html>
<head>
    <title>箱子管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="/css/bootstrap-responsive.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css" href="/css/style.css">
    <script src="/lib/jq/jquery-2.1.1.min.js"></script>
    <script src="lib/jq/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap-paginator.min.js"></script>
    <script type="text/javascript" src="/js/jquery.qrcode.min.js"></script>
    <script type="text/javascript">
        $(function(){

            //获得浏览器参数
            $.extend({
                getUrlVars: function(){
                    var vars = [], hash;
                    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                    for(var i = 0; i
                            < hashes.length; i++){
                        hash = hashes[i].split('=');
                        vars.push(hash[0]);
                        vars[hash[0]] = hash[1];
                    }
                    return vars;
                },
                getUrlVar: function(name){
                    return $.getUrlVars()[name];
                }
            });

            //封装浏览器参数
            var composeUrlParams=function(){
                var param='';
                $.each($.getUrlVars(), function(i, item) {
                    if(item!='p'){
                        var val=$.getUrlVar(item);
                        if(val) param += "&" + item+"="+val;
                    }
                });
                return param;
            }

            //分页功能
            var options = {
                currentPage:<%- page.num %>,
                totalPages:<%- page.pageCount %>,
                numberOfPages:5,
                pageUrl: function(type, page, current) {    //页面跳转
                    if(page!=<%- page.num %>){
                        return '/box_management/buyer?num='+ page;
                    }
                }
            }
            $('#page3').bootstrapPaginator(options);
        })
    </script>
</head>
<body style="margin:15px;">
<div id="lert"></div>
<% if (success) { %>
<div class="alert alert-success">
    <h4><%= success %></h4>
</div>
<% } %>
<% if (error) { %>
<div class="alert alert-error">
    <h4><%= error %></h4>
</div>
<% } %>
<legend>用户管理</legend>
    <a href="/box_management/create_buyer">
        <input type="button" style="width:55px;height:30px;background-color:#DBDBDB;border:1px solid #DBDBDB;border-radius:3px;" value="新增">
    </a>
    <table class="table table-bordered" style="margin-top: 15px;">
        <tr>
            <td style="text-align: center;width: 15%"><b>用户名</b></td>
            <td style="text-align: center;width: 15%"><b>登陆账号</b></td>
            <td style="text-align: center;width: 15%"><b>联系电话</b></td>
            <td style="text-align: center;width: 30%"><b>所属公司</b></td>
            <td style="text-align: center;width: 5%"><b>等级</b></td>
            <td style="text-align: center;width: 15%"><b>操作</b></td>
        </tr>
        <% for(var i=0;i<datas.length;i++){%>
        <tr>
            <td style="text-align: center;width: 15%"><%=datas[i].buyer%></td>
            <td style="text-align: center;width: 15%"><%=datas[i].account%></td>
            <td style="text-align: center;width: 15%"><%=datas[i].phoneNumber%></td>
            <td style="text-align: center;width: 30%"><%=datas[i].company%></td>
            <td style="text-align: center;width: 5%"><%=datas[i].level%></td>
            <td style="text-align: center;width: 15%">
                <a href="/box_management/update_buyer?id=<%=datas[i]._id%>&&buyer=<%=datas[i].buyer%>&&phoneNumber=<%=datas[i].phoneNumber%>&&company=<%=datas[i].company%>&&level=<%=datas[i].level%>" style="text-decoration: none">
                    <input type="button" style="width:55px;height:30px;background-color:#DBDBDB;border:1px solid #DBDBDB;border-radius:3px;" value="编辑">
                </a>
                <a href="/box_management/remo_buyer?buyerid=<%=datas[i].buyer_id%>&&buyer=<%=datas[i].buyer%>" onclick="return confirm('确定删除该用户?')" style="text-decoration: none">
                    <input type="button" style="width:55px;height:30px;background-color:#DBDBDB;border:1px solid #DBDBDB;border-radius:3px;" value="删除"/>
                </a>
            </td>
        </tr>
        <%}%>
    </table>
    <div id="page3" style="margin-bottom:0"></div>
</body>
</html>